<script type="text/javascript">
	function loadSignOrderInfo() {
		var orderNo = $('#SignOrderNo').val();
		$.post('transOrderScan.do?loadTransOrderLastestScanInfo',{orderNo:orderNo},function(result){
			 if (result.success){
	           	 $("#SignOrderScanForm").form('load', result.obj);
	           	 if('${(SIGN_SCAN_AUTO_SAVE)!}'=='Y') {
	           	   window.setTimeout("saveSignOrderScan()" , 500);
	           	 }
	           } else {
	        	   showMsg(result.msg,3000);
	           }
	        },'json');
	}
	
	function saveSignOrderScan() {
		var validate = $('#SignOrderScanForm').form("validate");
		if(validate) {
			var actionurl = $('#SignOrderScanForm').attr('action');//提交路径
			var formData = new Object();

			var fields = $('#SignOrderScanForm').serializeArray(); //自动序列化表单元素为JSON对象  

			$.each(fields, function(i, field) {
				printLog(field.name + "=" + field.value);
				formData[field.name] = field.value;
			});
			printLog(formData);
			jmaxAjax(actionurl,formData,function(rs) {
				resetScanInfo('SignOrderScanForm','signScanWebsite','${(personWebsiteId)!}');
				reloadSignOrderScan();
			});
		}
	}
	//表格查询  
	function reloadSignOrderScan() {
		var params = SignOrderScan_list.datagrid('options').queryParams; //先取得 datagrid 的查询参数  
		printLog(params);
		SignOrderScan_list.datagrid('reload'); //设置好查询参数 reload 一下就可以了  
		SignOrderScan_list.datagrid('unselectAll');
		SignOrderScan_list.datagrid('uncheckAll');
	}
	
	function deleteSignOrderScan() {
		var rows = SignOrderScan_list.datagrid('getChecked');
	    if (rows&&rows.length>0){
	        $.messager.confirm('询问','你确认要删除吗?',function(r){
	            if (r){
	            	var ids = "";
	            	for(var i=0; i<rows.length; i++){
	            		ids += rows[i].id+",";
	            	}
	                $.post('transOrderScan.do?deleteTransOrderScanItems',{ids:ids},function(result){
	                    if (result.success){
	                    	reloadSignOrderScan();    
	                    }
	                    showMsg(result.msg);
	                },'json');
	            }
	        });
	    }else {
	    	showMsg("请选择操作记录.");
	    }
	}
	
	function addSignOrderScan() {
		resetScanInfo('SignOrderScanForm','signScanWebsite','${(personWebsiteId)!}');
	}
</script>
<div class="easyui-layout" data-options="fit:true">
	 <div data-options="region:'north',border:false" style="height:100px;overflow: hidden;background:#F4F4F4">
       	<div id="SignOrderScan_toolbar" style="border-bottom:1px solid #ddd;height: auto">
			<@eu.linkbutton showName="新增" shiro="trans:signOrderScan:add" iconCls="icon-add" onclick="addSignOrderScan()"/>
			<@eu.linkbutton showName="更新或保存" shiro="trans:signOrderScan:saveOrUpdate" iconCls="icon-save" onclick="saveSignOrderScan()"/>
		</div>
	    <form id="SignOrderScanForm" action="transOrderScan.do?sureSignScan">
	    	<input type="hidden" name="startWebsiteId" />
	    	<table>
	    		<tr>
	    			<td class="tbLabel" rowspan="2">运单号:</td>
	    			<td rowspan="2"><input id="SignOrderNo" style="height: 40px;width:200px;" name="orderNo" class="easyui-validatebox textbox" onchange="loadSignOrderInfo()"/></td>
	    			<td class="tbLabel">签收人:</td>
	    			<td><input class="easyui-validatebox textbox" name="signName" /></td>
	    			<td class="tbLabel">签收时间:</td>
	    			<td>
						<input name="signTime" style="width:160px;" class="easyui-datetimebox" data-options="required: true" />
					</td>
					<td class="tbLabel">签收状态:</td>
	    			<td>
	    				<@eu.comboBox url="common.do?loadComboBox&key=SIGN_STATUS" name="signStatus" required="true"/>
	    			</td>
	    			<td>目的站:</td>
	    			<td>
	    				<@eu.comboBox url="transWebSite.do?loadWebsiteCombox" disabled="true" name="endWebsiteId" required="true" />
	    			</td>
	    		</tr>
	    		<tr>
	    			<td>派件人:</td>
	    			<td><input class="easyui-validatebox textbox" name="deliveryName" readonly="readonly"/></td>
	    			<td>派件人电话:</td>
	    			<td>
						<input class="easyui-validatebox textbox"  name="deliveryPhone" readonly="readonly"/>	    			
					</td>
					<td>当前网点:</td>
	    			<td>
	    				<input type="hidden" name="startWebsiteId" />
	    				<@eu.comboBox id="signScanWebsite" disabled="true" url="transWebSite.do?loadWebsiteCombox&value=${(personWebsiteId)!}" name="currentWebsiteId" required="true" />
	    			</td>
	    			
	    		</tr>
	    	</table>
	    </form>
     </div>
	<div data-options="region:'center',border:false,title:'扫描清单'">
		<@eu.datagrid id="SignOrderScan_list" idField="id" 
			 url="transOrderScan.do?loadSignScanList&scanType=5&creator=${(user.loginName)!}" rownumbers="true" toolbar="#SignOrderScanListSearch"
			 item="com.xdtech.trans.vo.OrderSignScanItem"/>
		<div id="SignOrderScanListSearch">
			<div id="SignOrderScanToolbar" style="height: auto">
				<@eu.linkbutton showName="删除" shiro="trans:signOrderScan:delete" iconCls="icon-remove" onclick="deleteSignOrderScan()"/>
			</div>
		</div>
	</div>
</div>